using System.ComponentModel.DataAnnotations;

namespace ChatBackend.DTOs
{
    public class RegisterDto
    {
        [Required(ErrorMessage = "用户名是必需的")]
        [StringLength(50, MinimumLength = 3, ErrorMessage = "用户名长度必须在3-50个字符之间")]
        public string Username { get; set; } = string.Empty;

        [Required(ErrorMessage = "邮箱是必需的")]
        [EmailAddress(ErrorMessage = "邮箱格式不正确")]
        [StringLength(100, ErrorMessage = "邮箱长度不能超过100个字符")]
        public string Email { get; set; } = string.Empty;

        [Required(ErrorMessage = "密码是必需的")]
        [StringLength(100, MinimumLength = 6, ErrorMessage = "密码长度必须在6-100个字符之间")]
        public string Password { get; set; } = string.Empty;

        [StringLength(100, ErrorMessage = "显示名称长度不能超过100个字符")]
        public string? DisplayName { get; set; }
    }

    public class LoginDto
    {
        [Required(ErrorMessage = "用户名或邮箱是必需的")]
        public string UsernameOrEmail { get; set; } = string.Empty;

        [Required(ErrorMessage = "密码是必需的")]
        public string Password { get; set; } = string.Empty;
    }

    public class AuthResponseDto
    {
        public string Token { get; set; } = string.Empty;
        public UserDto User { get; set; } = new();
        public DateTime ExpiresAt { get; set; }
    }

    public class UserDto
    {
        public int Id { get; set; }
        public string Username { get; set; } = string.Empty;
        public string Email { get; set; } = string.Empty;
        public string? DisplayName { get; set; }
        public string? Avatar { get; set; }
        public bool IsOnline { get; set; }
        public DateTime? LastSeenAt { get; set; }
        public DateTime CreatedAt { get; set; }
    }
}
